import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

export default defineConfig({
  plugins: [react()],
  server: {
    proxy: {
      '/api': {
        target: 'http://localhost:80',
        changeOrigin: true,
        // rewrite: (path) => path.replace(/^\/api/, '')
      },
      '/images': {
        target: 'http://localhost:80',
        changeOrigin: true,
      }
    },
    fs: {
      strict: false
    }
  },
  build: {
    outDir: 'dist', // 指定输出目录
    assetsInlineLimit: 4096, // 小于4KB的资源会被内联
    minify: 'terser', // 使用terser进行代码压缩
    sourcemap: false, // 生产环境关闭sourcemap
    rollupOptions: {
      output: {
        manualChunks: {
          react: ['react', 'react-dom'], // 将react相关代码单独打包
        }
      }
    }
  },
  publicDir: 'src/public',
})